﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class EncodeAndEncrypt
    {
        static void Main()
        {

            char[] message = Console.ReadLine().ToCharArray();
            string cypher = Console.ReadLine();
            char[] cypherArray = cypher.ToCharArray();

            var encrypted = Encrypt(message, cypherArray);
            encrypted.Append(cypher);

            var result = Encode(encrypted);
            result.Append(cypher.Length);
            Console.WriteLine(result);
        }

        static StringBuilder Encrypt(char[] message, char[] cypher)
        {
            StringBuilder result = new StringBuilder();
            int j = 0;
            
            if (message.Length > cypher.Length)
            {
                for (int i = 0; i < message.Length; i++)
                {
                    j = i % cypher.Length;
                    
                    message[i] -= 'A';
                    char useCypher = (char)(cypher[j] - 'A');
                    message[i] ^= useCypher;
                    
                    message[i] += 'A';
                    result.Append(message[i]);
                }
            }
            else
            {
                // the same as above:
                for (int i = 0; i < cypher.Length; i++)
                {
                    j = i % message.Length;

                    message[j] -= 'A';
                    char encryptChar = (char)(cypher[i] - 'A');
                    message[j] ^= encryptChar;

                    message[j] += 'A';

                    // put the newly encrypted char in front and delete the previous value of it
                    if (i >= message.Length)
                    {
                        result.Insert(j, message[j]);
                        result.Remove(j + 1, 1);
                    }
                    else
                    {
                        result.Append(message[j]);
                    }                
                }

            }
            return result;
        }

        static StringBuilder Encode(StringBuilder input)
        {
            
            StringBuilder compressed = new StringBuilder();
            int count = 1;
            char previous = input[0];

            for (int i = 1; i < input.Length; i++)
            {
                if (input[i].Equals(previous))
                {
                    count++;
                }
                else
                {
                    if (count == 1)
                    {
                        compressed.Append(previous);
                    }
                    else if (count == 2)
                    {
                        compressed.Append(previous, 2);
                    }
                    else if (count > 2)
                    {
                        compressed.Append(count);
                        compressed.Append(previous);
                    }

                    count = 1;
                }

                previous = input[i];
                
            }

            if (count == 1)
            {
                compressed.Append(previous);
            }
            else if (count == 2)
            {
                compressed.Append(previous, 2);
            }
            else if (count > 2)
            {
                compressed.Append(count);
                compressed.Append(previous);
            }

            return compressed;

        }
}

